package com.jiesen.base.utils;

import org.apache.shiro.crypto.hash.Md5Hash;

public class MD5Utils {

    public static String getPasswordToMd5(String password){
        Md5Hash md5Hash1 = new Md5Hash(password, "jiesen", 1);
        String s = md5Hash1.toString();
        return s;
    }

    /**
     *
     * @param password1 输入的密码
     * @param password2 数据库密码
     * @param salt  盐
     * @return
     */
    public static boolean passwordCompare(String password1,String password2,String salt){
        Md5Hash md5Hash1 = new Md5Hash(password1, salt, 1);
        password1 = md5Hash1.toString();
        return password1.equals(password2);
    }

    /**
     *
     * @param password1 输入的密码
     * @param password2 数据库密码
     * @return
     */
    public static boolean passwordCompare(String password1,String password2){
        Md5Hash md5Hash1 = new Md5Hash(password1, "jiesen", 1);
        password1 = md5Hash1.toString();
        return password1.equals(password2);
    }

}
